/**
 * 作者：陈文斌 on 2019/1/5.
 * 邮箱：chen_wennbin@163.com
 * 版本：v1.0
 */

import 'package:flutter/material.dart';
import 'package:crm/constant/constant.dart';
import 'package:crm/model/main_scoped_model.dart';
import 'package:crm/model/ClientManager/client_info_model.dart';
import 'package:crm/component/ClientManager/client_manager_company_name_phone_section.dart';
import 'package:crm/component/ClientManager/client_manager_address_section.dart';
import 'package:crm/component/ClientManager/client_manager_tile_section.dart';

class ClientManagerArrangementRow extends StatefulWidget {
  final ClientInfoModel clientInfo;

  @override
  ClientManagerArrangementRow({
    Key key,
    this.clientInfo,
  }) : super(key: key);

  State<StatefulWidget> createState() => _ClientManagerArrangementRowState();
}

class _ClientManagerArrangementRowState
    extends State<ClientManagerArrangementRow> {
  bool _isSpreadOut;

  @override
  void initState() {
    final clientManagerScopedModel = MainModel().of(context);
    _isSpreadOut = !clientManagerScopedModel.clientManagerListIsArrangement;
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(
        top: 5,
      ),
      padding: EdgeInsets.fromLTRB(
        AppScreen.setWidth(17),
        11,
        0,
        11,
      ),
      color: Colors.white,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          GestureDetector(
            behavior: HitTestBehavior.translucent,
            onTap: () {
              _isSpreadOut = !_isSpreadOut;
              setState(() {});
            },
            child: Column(
              children: <Widget>[
                // 名字、电话
                CompanyNamePhoneSection(
                  companyName: widget.clientInfo.companyName,
                  companyType: widget.clientInfo.industryClassification,
                  phone: widget.clientInfo.phone,
                ),
                Padding(padding: EdgeInsets.only(top: 9)),
                // 地址部分
                AddressSection(
                  streetAddress: widget.clientInfo.streetaddress,
                ),
              ],
            ),
          ),
          // 展开部分
          _isSpreadOut
              ? ClientManagerTileSection(
                  client: widget.clientInfo,
                )
              : Container(),
        ],
      ),
    );
  }
}
